package com.foryou.system;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

/**
 * 单链表反转
 */
public class Test {


    public static void main(String[] args) {
        Node node1 = new Test.Node(1);
        Node node2 = new Test.Node(2);
        Node node3 = new Test.Node(3);
        node1.next = node2;
        node2.next = node3;

        nodeReliver(node1);


        //1->2->3 => 3->2->1
    }

    public  static void nodeReliver(Node node) {
        if (node.next == null) {
            return;
        }
        reset(node);
    }

    // grep  |java
    // kill -9 22

    public static Node reset(Node node) {
        node.next = node;
        return reset(node);
    }

    @Data
    @NoArgsConstructor
    static class Node{
        private Node next;
        private int value;

        public Node(int value) {
            this.value = value;
        }

    }
}
